package com.example.a24644.myapplication;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

    private EditText userName;
    private TextView passWord;
    private Button button;
    private TextView textView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        userName = (EditText) findViewById(R.id. userNameText);
        passWord = (EditText) findViewById(R.id.passwordText);
        button = (Button) findViewById(R.id.loginbtn);
        textView = (TextView) findViewById(R.id.tips);


        button.setOnClickListener(new View.OnClickListener(){

            @Override

            public void onClick(View v){
                String usernema =userName.getText().toString();
                String prassword = passWord.getText().toString();

                if(!"201958501318".equals(usernema)){
                    textView.setText("Toast");
                    textView.setVisibility(View.VISIBLE);
                    return;
                }
                if (!"1234".equals(prassword)){
                    textView.setText("Toast");
                    textView.setVisibility(View.VISIBLE);
                    return;
                }
                if ("201958501318".equals(usernema)&&"1234".equals(prassword)){
                    textView.setText("登陆成功");
                    textView.setVisibility(View.VISIBLE);

                    Intent intent = new Intent(MainActivity.this,Main2Activity.class);
                    startActivity(intent);
                }

            }
        });



    }

}